package io.bluerain.contentprovider;

import android.app.Activity;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;

/**
 * Created by foredawn on 15-9-13.
 * ContentReceiver基本用法
 */
public class ContentReceiverTest extends Activity {

    ContentResolver resolver;
    Uri uri;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.conetnt_receiver_activity);
        uri = Uri.parse("content://io.bluerain.provider/");
        resolver = getContentResolver();

    }

    public void insert(View source) {
        ContentValues values = new ContentValues();
        values.put("name", "小明");
        resolver.insert(uri, values);
    }

    public void update(View source) {
        ContentValues values = new ContentValues();
        values.put("name", "张三");
        resolver.update(uri, values, "update_where", null);
    }

    public void query(View source) {
        resolver.query(uri, null, "query_where", null, null);
    }

    public void delete(View source) {
        resolver.delete(uri, "delete_where", null);
    }
}
